﻿{% extends "gma/base.html" %}
{% load mytag %}

<!-- CONTENT
  =====================================================================-->

{% block content %}

<div class="page__hd">
    <h1 class="page__title">
        <i class="fa fa-video weui_grid_icon_fa" style="font-size: 32px;"> </i> 视频审核
    </h1>
{#    <p class="page__desc">  </p>#}
</div>

<div class="page__bd">
    <div class="weui-cells__title">基本信息</div>
    <div class="weui-cells">
        <a class="weui-cell weui-cell_access" href="{% url 'gma:caster_detail' user.uid %}">
            <div class="weui-cell__bd"> <p>[{{ user.id }}] {{ user.auth_nickname }}</p> </div>
            <div class="weui-cell__ft"> <img src="{{ user.avatar|cdn }}" class="right_large_avatar"> </div>
        </a>

        <div class="weui-cell">
            <div class="weui-cell__bd"> <p>视频ID</p> </div>
            <div class="weui-cell__ft"> #{{ video.id }} </div>
        </div>

        <div class="weui-cell weui-cell_access" id="showStarActionSheet">
            <div class="weui-cell__bd"> <p>视频星级</p> </div>
            <div class="weui-cell__ft">{{ video.star_desp }}</div>
        </div>

        {% if permissions.set_cast_price.open %}
        <div class="weui-cell" id="showVideoPriceActionSheet">
            <div class="weui-cell__bd"> <p>视频价格</p> </div>
            <div class="weui-cell__ft"> {{ video.price }}钻石 </div>
        </div>
        {% else %}
        <div class="weui-cell">
            <div class="weui-cell__bd"> <p>视频价格</p> </div>
            <div class="weui-cell__ft"> {{ video.price }}钻石 </div>
        </div>
        {% endif %}
    </div>

    <div class="weui-cells__title">待审视频</div>
    <div align="center">
        <video class="pp-video " src="{{ video.video_url|cdn }}" controls="controls">
        您的浏览器不支持 video 标签。
        </video>
    </div>

    <br>
</div>

<div class="weui-btn-area">
    {% if video.auth_status == 1 %}
        <a class="weui-btn weui-btn_block weui-btn_primary" href="javascript:agree()">同意上架</a>
        <a class="weui-btn weui-btn_block weui-btn_warn" href="javascript:reject()">拒绝上架</a>
    {% elif video.auth_status == 2 %}
        <a class="weui-btn weui-btn_block weui-btn_primary" href="javascript:agree()">同意上架</a>
    {% elif video.auth_status == 3 %}
        <a class="weui-btn weui-btn_block weui-btn_warn" href="javascript:reject()">拒绝上架</a>
    {% endif %}

    {% if video.auth_status == 3 %}
        {% if video.is_calling_video == 1 %}
            <a class="weui-btn weui-btn_block weui-btn_warn" href="javascript:setCallingVideo(0)">取消呼叫视频</a>
        {% else %}
            <a class="weui-btn weui-btn_block weui-btn_primary" href="javascript:setCallingVideo(1)">设置为呼叫视频</a>
        {% endif %}
    {% endif %}
</div>


<div class="weui-mask" id="starMask" style="display: none"></div>
<div class="weui-actionsheet" id="starActionsheet">
    <div class="weui-actionsheet__title">
        <p class="weui-actionsheet__title-text">设置视频星级</p>
    </div>
    <div class="weui-actionsheet__menu">
        <div class="weui-actionsheet__cell" onclick="javascript:set_video_star(0)"> 去除星级 </div>
        <div class="weui-actionsheet__cell" onclick="javascript:set_video_star(1)"> ⭐ </div>
        <div class="weui-actionsheet__cell" onclick="javascript:set_video_star(2)"> ⭐⭐ </div>
        <div class="weui-actionsheet__cell" onclick="javascript:set_video_star(3)"> ⭐⭐⭐ </div>
        <div class="weui-actionsheet__cell" onclick="javascript:set_video_star(4)"> ⭐⭐⭐⭐ </div>
        <div class="weui-actionsheet__cell" onclick="javascript:set_video_star(5)"> ⭐⭐⭐⭐⭐ </div>
    </div>
    <div class="weui-actionsheet__action">
        <div class="weui-actionsheet__cell" id="starActionsheetCancel">取消</div>
    </div>
</div>


{% if permissions.set_cast_price.open %}
    <div class="weui-mask" id="videoPriceMask" style="display: none"></div>
    <div class="weui-actionsheet" id="videoPriceActionsheet">
        <div class="weui-actionsheet__title">
            <p class="weui-actionsheet__title-text">设置视频价格</p>
        </div>
        <div class="weui-actionsheet__menu">
            {% if video.price != 0 %}
                <div class="weui-actionsheet__cell" onclick="javascript:set_video_price(0)"> <b>0</b> 钻石</div>
            {% endif %}

            {% if video.price != 1 %}
            <div class="weui-actionsheet__cell" onclick="javascript:set_video_price(1)"> <b>1</b> 钻石</div>
            {% endif %}

            {% if video.price != 2 %}
            <div class="weui-actionsheet__cell" onclick="javascript:set_video_price(2)"> <b>2</b> 钻石</div>
            {% endif %}

            {% if video.price != 5 %}
            <div class="weui-actionsheet__cell" onclick="javascript:set_video_price(5)"> <b>5</b> 钻石</div>
            {% endif %}

            {% if video.price != 8 %}
            <div class="weui-actionsheet__cell" onclick="javascript:set_video_price(8)"> <b>8</b> 钻石</div>
            {% endif %}

            {% if video.price != 10 %}
            <div class="weui-actionsheet__cell" onclick="javascript:set_video_price(10)"> <b>10</b> 钻石</div>
            {% endif %}

            {% if video.price != 12 %}
            <div class="weui-actionsheet__cell" onclick="javascript:set_video_price(12)"> <b>12</b> 钻石</div>
            {% endif %}

            {% if video.price != 15 %}
            <div class="weui-actionsheet__cell" onclick="javascript:set_video_price(15)"> <b>15</b> 钻石</div>
            {% endif %}

            {% if video.price != 20 %}
            <div class="weui-actionsheet__cell" onclick="javascript:set_video_price(20)"> <b>20</b> 钻石</div>
            {% endif %}

            {% if video.price != 25 %}
            <div class="weui-actionsheet__cell" onclick="javascript:set_video_price(25)"> <b>25</b> 钻石</div>
            {% endif %}

            {% if video.price != 30 %}
            <div class="weui-actionsheet__cell" onclick="javascript:set_video_price(30)"> <b>30</b> 钻石</div>
            {% endif %}
        </div>
        <div class="weui-actionsheet__action">
            <div class="weui-actionsheet__cell" id="videoPriceActionsheetCancel">取消</div>
        </div>
    </div>
{% endif %}

<div class="page__ft">
    <a href="{% url 'gma:home' %}">
        <span class="bottom-logo">
           HiBao
       </span>
    </a>
</div>

{% endblock content %}


<!-- SCRIPT
  =====================================================================-->

{% block extra_js %}

<script type="text/javascript" class="actionsheet js_show">
$(function(){
    let $starActionsheet = $('#starActionsheet');
    let $mask = $('#starMask');

    function hideActionSheet() {
        $starActionsheet.removeClass('weui-actionsheet_toggle');
        $mask.fadeOut(200);
    }

    $mask.on('click', hideActionSheet);
    $('#starActionsheetCancel').on('click', hideActionSheet);
    $("#showStarActionSheet").on("click", function(){
        $starActionsheet.addClass('weui-actionsheet_toggle');
        $mask.fadeIn(200);
    });
});

function set_video_star(star) {
    let url = "{% url 'gma:api_set_video_star' %}";
    let data = {
        'video_id': {{ video.id }},
        'star': star,
    };

    new my_ajax(url, data, '', '', () => {
        show_toast(`星级设置成功！`);
        setTimeout(() => {
            window.location.reload();
        }, 1000);
    });
}
</script>

<script>
function agree() {
    let url = "{% url 'gma:api_agree_video' %}";
    let data = {
        'video_id': {{ video.id }},
    };

    new my_ajax(url, data, '', '', () => {
        show_toast("同意该视频上架!");
        window.history.back();
    });
}

function reject() {
    let url = "{% url 'gma:api_reject_video' %}";
    let data = {
        'video_id': {{ video.id }},
    };

    new my_ajax(url, data, '', '', () => {
        show_toast("拒绝该视频上架!");
        window.history.back();
    });
}

function setCallingVideo(is_calling_video) {
    let url = "{% url 'gma:api_set_calling_video' %}";
    let data = {
        'video_id': {{ video.id }},
        'is_calling_video': is_calling_video,
    };

    new my_ajax(url, data, '', '', () => {
        show_toast("设置成功!");
        window.history.back();
    });
}
</script>

{% if permissions.set_cast_price.open %}
<script type="text/javascript" class="actionsheet js_show">
$(function(){
    let $sheet = $('#videoPriceActionsheet');
    let $mask = $('#videoPriceMask');

    function hideActionSheet() {
        $sheet.removeClass('weui-actionsheet_toggle');
        $mask.fadeOut(200);
    }

    $mask.on('click', hideActionSheet);
    $('#videoPriceActionsheetCancel').on('click', hideActionSheet);
    $("#showVideoPriceActionSheet").on("click", function(){
        $sheet.addClass('weui-actionsheet_toggle');
        $mask.fadeIn(200);
    });
});

function set_video_price(price) {
    let url = "{% url 'gma:api_set_video_price' %}";
    let data = {
        'vid': {{ video.id }},
        'price': price,
    };

    new my_ajax(url, data, '', '', () => {
        show_toast(`视频价格设置为${price}钻石!`);
        setTimeout(() => {
            window.location.reload();
        }, 1000);
    });
}
</script>
{% endif %}

{% endblock extra_js %}